# -*- coding: utf8 -*-
# $Id :  $



# Copyright 2008-2010, Pascal Fautrero & JCharles
#
# This file is part of PyArchiver.
# 
# PyArchiver is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyArchiver is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyArchiver.  If not, see <http://www.gnu.org/licenses/>.



# Import packages

import wx                        # This module uses the new wx namespace
import images
import time
import locale

_ = wx.GetTranslation            # Define _ or add _ to builtins in your app file

#---------------------------------------------------------------------------

class My_CustomStatusBar(wx.StatusBar):
    def __init__(self, parent):
        wx.StatusBar.__init__(self, parent, -1)
        
        #-------------------------------------------------------------------
        
        self.parent = parent
        
        #-------------------------------------------------------------------
        
        self.SetFieldsCount(2)
        self.SetStatusWidths([-6, 225])
        
        #-------------------------------------------------------------------

        bmp = images.Calendar.GetBitmap()
        self.img = wx.StaticBitmap(self, -1)
        self.img.SetBitmap(bmp)
        
        # Bind a size event to an events handler
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.PlaceIcon()
        
        #-------------------------------------------------------------------
        
        self.statusbar_fields = [_("Welcome to PyArchiver !"),
                                 ("")]
        
        for i in range(len(self.statusbar_fields)):
            self.SetStatusText(self.statusbar_fields[i], i)
     
        #-------------------------------------------------------------------
        
        self.timer = wx.PyTimer(self.Notify)
        # Update every 1000 milliseconds
        self.timer.Start(1000)
        self.Notify()
     
    #-----------------------------------------------------------------------
     
    def PlaceIcon(self):
        rect = self.GetFieldRect(1)
        self.img.SetPosition((rect.x+3, rect.y+1))
     
     
    def OnSize(self, event):
        self.PlaceIcon()
     
     
    # Handles events from the timer we started in __init__().
    # We're using it to drive a 'clock' in field 2.
    def Notify(self):
        """ Timer event """
     
        locale.setlocale(locale.LC_ALL,"")
        tm = time.strftime(_("....    %a %Y %b %d - %Hh%M"))
     
        self.SetStatusText(tm, 1)


